import Vue from 'vue'
import Router from 'vue-router'

import index from '@/components/index/index'
import User from '@/components/user/User'

import GoodsList from '@/components/goods/GoodList'
import GoodsAdd from  '@/components/goods/GoodsAdd'

import OrderList from '@/components/order/OrderList'

import FinanceBill from '@/components/finance/FinanceBill'

import LoginIndex from '@/components/login/index'

Vue.use(Router)

const originalPush = Router.prototype.push
Router.prototype.push = function push( location) {
  return originalPush.call(this, location).catch(err => err)
}

export default new Router({
  routes: [
    {
      path: '/',
      name: 'index',
      component: index,
      children: [
        //首页以及用户中心
        {
          path: '/',
          name: 'user',
          component: User
        },
        {
          path: '/index/user',
          name: 'User',
          component: User
        },

        //商品管理
        {
          path: '/goods/list',
          name: 'GoodsList',
          component: GoodsList
        },
        {
          path: '/goods/add',
          name: 'GoodsAdd',
          component: GoodsAdd
        },

        //订单管理
        {
          path: '/order/list',
          name: 'OrderList',
          component: OrderList
        },

        //财务管理
        {
          path: '/finance/bill',
          name: 'FinanceBill',
          component: FinanceBill
        },


      ]
    },
    {
      path: '/login',
      name: 'LoginIndex',
      component: LoginIndex,
    }
  ]
})
